<!--
 * @Author: 吴竹叶 2107206923@qq.com
 * @Date: 2023-09-28 17:24:24
 * @LastEditors: 胡威 3749920422@qq.com
 * @LastEditTime: 2024-02-28 13:55:01
 * @FilePath: \BZ_JT_AnQuanHuanBaoGuanLiApp\src\views\staging\commom\evaluate\components\energySources\list.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div>
    <customSearch ref="customSearch" placeholder="请输入企业名称" title="企业列表" :total="total" :is-super-search="true" @search="handleSearch" @superSearch="openSuperSearch" />
    <div class="listInner">
      <div v-if="listData.length > 0" class="common_list">
        <div v-for="(item, index) in listData" :key="index" class="list_item" @click="goToDetails(item)">
          <div class="content_area">
            <div class="number_order">{{ index + 1 }}</div>
            <div class="right_content">
              <div class="content_title" style="max-width: 100%">
                {{ item.companyName }}
              </div>
              <ul>
                <li>
                  <i class="iconfont c-text-primary">&#xe727;</i>
                  <div class="label">得分：</div>
                  <div class="value">{{ item.totalScore }}</div>
                </li>
                <li>
                  <i class="iconfont c-text-success">&#xe685;</i>
                  <div class="label">评分时间：</div>
                  <div class="value">{{ item.scoringTime }}</div>
                </li>
                <li>
                  <i class="iconfont c-text-warning">&#xe6b6;</i>
                  <div class="label">排名：</div>
                  <div class="value">{{ item.rank }}  {{ item['compareBefore']?`（${item['compareBefore']}）`:'/' }}</div>
                </li>
              </ul>
            </div>
          </div>
        </div>
      </div>
      <customLoadmore ref="customLoadmore" :page-num="formInline.pageNum" :pages="pages" @load="handlePages" />
    </div>
    <van-popup v-model="superSearch" position="right" :style="{ width: '90%', height: '100%' }" lock-scroll close-on-popstate closeable class="custom-van-pop">
      <div class="pop-vertical-flex">
        <div class="pop-content">
          <custom-timer placeholder="请选择评分时间" type="year-month" :is-title="true" title="评分时间" :is-interval="false" :date-value.sync="formInline.scoreTime" />
        </div>
        <div class="pop-bottom">
          <!--          <van-button type="default" @click="resetSuperSearch">清空</van-button>-->
          <!--          评分时间不能清空  所以删除清空按钮-->
          <van-button style="width: 80%;border-radius: 50px" type="info" @click="handleSuperSearch">确认</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import commonList from '@/assets/mixin/commonList'
import { currentTime } from '@/utils/dayJs'
import { pagePort } from './config.js'

export default {
  mixins: [commonList],
  data() {
    return {
      current: '',
      formInline: {
        pageNum: 1,
        pageSize: 10,
        companyName: '',
        companyScoreSort: 'desc',
        scoreTime: currentTime('年月')
        // scoreTime: '2024-01'
      },
      listData: []
    }
  },
  computed: {
    configField() {
      return `${this.$route.query.current}`
    },
    getPort() {
      return pagePort[this.configField] ?? false
    }
  },
  mounted() {
    const { current } = this.$route.query
    if (current) {
      this.current = current
    }
    this.getListData()
  },
  methods: {
    tagChange(tagArg) {
      this.list.map((v) => {
        if (v.label === tagArg.active) {
          this.currentComponent = v.value
        }
      })
    },
    // 分页
    handlePages(value) {
      this.formInline.pageNum = value
      this.getListData()
    },
    // 打开高级查询弹窗
    openSuperSearch() {
      this.superSearch = true
    },
    // 企业名称查询
    handleSearch(value) {
      this.formInline.companyName = value
      this.formInline.pageNum = 1
      this.listData = []
      this.getListData()
    },
    // 跳转详情
    goToDetails(item) {
      this.$router.push({
        path: '/staging/evaluateDetails',
        query: { current: this.current, scoreTime: this.formInline.scoreTime, ...item }
      })
    },
    // 返回工作台
    back() {
      this.$router.push({
        path: '/staging/monitor',
        query: { current: this.current }
      })
    },
    // 获取企业列表数据
    async getListData(isReset) {
      this.$refs.customLoadmore.loadStatus = true
      this.layout.showLoading()
      const { status, data } = await this.getPort.ListPort(this.formInline)
      if (status === 0 && data) {
        this.total = data.total
        isReset ? this.listData = data.list : this.listData = this.listData.concat(data.list)
        this.pages = data.pages
      }
      this.$refs.customLoadmore.loadStatus = false
      this.layout.hideLoading()
    },
    resetSuperSearch() {
      Object.keys(this.formInline).forEach(v => {
        this.formInline[v] = ''
      })
      this.$refs.customSearch.restore()
      this.formInline.pageNum = 1
      this.formInline.pageSize = 10
      this.formInline.companyIds = -1
    },
    handleSuperSearch() {
      this.superSearch = false
      this.getListData({ isReset: true })
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
